#doc----------------------------------------------------------------
#所有参数 显示格式为NBT路径(NBT路径以宏参数内的register为根目录)
#String | trigger_run.trigger: 触发时触发者运行
#String | trigger_run.main_run: 触发时基座Main实体运行
#String | trigger_run.exhaust: 当使用次数耗尽时运行
#String(Text Component) | name: 显示名称
#Compound | display_item: 显示的物品
#Int | count: 可以被触发的次数（默认为1，若填写最小为2）
#Compound | custom_tf: 自定义transformation
#Boolean | player_can_reuse: 单个玩家是否可以重复使用（当有count参数时才可使用）
#doc----------------------------------------------------------------

#格式检查
execute if data storage dab:register parser.trigger_run.trigger run function dab:system/register/format_check {type:"string",path:"from storage dab:register parser.trigger_run.trigger"}
execute if data storage dab:register parser.trigger_run.main_run run function dab:system/register/format_check {type:"string",path:"from storage dab:register parser.trigger_run.main_run"}
execute if data storage dab:register parser.trigger_run.exhaust run function dab:system/register/format_check {type:"string",path:"from storage dab:register parser.trigger_run.exhaust"}
execute if data storage dab:register parser.name run function dab:system/register/format_check {type:"string",path:"from storage dab:register parser.name"}
execute if data storage dab:register parser.display_item run function dab:system/register/format_check {type:"compound",path:"from storage dab:register parser.display_item"}
execute if data storage dab:register parser.count run function dab:system/register/format_check {type:"int",path:"from storage dab:register parser.count"}
execute if data storage dab:register parser.custom_tf run function dab:system/register/format_check {type:"compound",path:"from storage dab:register parser.custom_tf"}
execute if data storage dab:register parser.player_can_reuse run function dab:system/register/format_check {type:"boolean",path:"from storage dab:register parser.player_can_reuse"}
execute unless data storage dab:register parser run return fail

#不可为空复合
execute store result score #CCount temp run data get storage dab:register parser.trigger_run
execute if score #CCount temp matches ..0 run return run function dab:system/register/mp_effect/.fail_null_compound

#最小值检查
execute if data storage dab:register parser.count store result score #Count temp run data get storage dab:register parser.count
execute if data storage dab:register parser.count unless score #Count temp matches 2.. run return run function dab:system/register/mp_effect/.fail_min_value

#前置检查
execute if data storage dab:register parser.player_can_reuse unless data storage dab:register parser.count run return run function dab:system/register/.fail/custom_tip {tip:'{"text":"注册失败,有player_can_reuse参数但缺少count参数","color":"red"}'}

#删除冗余键
function dab:system/register/.redundant_key_killer/start {protections:["trigger_run.trigger","trigger_run.main_run","trigger_run.exhaust","name","count","player_can_reuse","display_item","custom_tf"]}





scoreboard players reset #Count temp